package logic

import (
	"context"
	"medi-manage/models"

	"medi-manage/medirpc/internal/svc"
	"medi-manage/medirpc/medirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MediUpdatesLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMediUpdatesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MediUpdatesLogic {
	return &MediUpdatesLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 修改
func (l *MediUpdatesLogic) MediUpdates(in *medirpc.MediUpdatesRequest) (*medirpc.MediUpdatesResponse, error) {
	// todo: add your logic here and delete this line
	var medi models.Medi
	err := medi.MediUpdates(models.DB, in.MeidId)
	if err != nil {
		return nil, err
	}
	return &medirpc.MediUpdatesResponse{
		MeidId: int64(medi.ID),
		Name:   medi.Name,
		Images: medi.Image,
		Room:   medi.Room,
	}, nil
}
